﻿<!doctype html>
 <html lang="zh-CN"/>
 <head>
   <meta charset="UTF-8"/>
   <link rel="stylesheet" href="../../../css/common.css"/>
   <link rel="stylesheet" href="../../../css/main.css"/>
   <script type="text/javascript" src="../../../js/jquery.min.js"></script>
   <script type="text/javascript" src="../../../js/colResizable-1.3.min.js"></script>
   <script type="text/javascript" src="../../../js/common.js"></script>
  <script type="text/javascript">
	//全选
    /*全选方法*/
    $(function(){

        $("#buttonAll").click(function(){
            /*得到点击按钮的状态*/
            /*jq->js*/
            var status=$(this)[0].checked;
            //设置全选
            var cks=document.getElementsByName("userId");

            for (var i = 0; i < cks.length; i++) {
                console.log(cks[i])
                cks[i].checked=status;
            }
        })
    });

    //批量删除
    function deleteAll(){
        confirm("确认删除");
        var name = document.getElementsByName("userId");
        var sum=0;
        for (var i = 0; i <name.length ; i++) {
            if (name[i].checked==true){
                sum=1;
                break;
            }

        }
        if (sum==1) {
            document.getElementById("myMethod").value="deleteAll";
            document.forms[1].submit();
        } else {
            alert("请选择要导出的数据");
        }
    }


    //导出数据
    function excel(){
        confirm("确认导出");
        var name = document.getElementsByName("userId");
        var sum=0;
        for (var i = 0; i <name.length ; i++) {
            if (name[i].checked==true){
                sum=1;
                break;
            }

        }
        if (sum==1) {
            document.getElementById("myMethod").value = "doExcle";
            document.forms[1].submit();
        } else {
            alert("请选择要导出的数据");
        }
    }

  </script>
</head>
<body>
<form action="/resource/system/user/list" method="post">
     <div id="search_bar" class="mt10">
       <div class="box">
          <div class="box_border">
            <div class="box_top"><b class="pl15">搜索</b></div>
            <div class="box_center pt10 pb10">
              <table class="form_table" border="0" cellpadding="0" cellspacing="0">
                <tr>
                  <td>姓名</td>
                  <td>

                      <input type="text" name="username"  value="${username}"   class="input-text lh25" size="10"/>
                  </td>

                  <td>真实姓名</td>
                  <td>
                      <input type="text" name="realName" value="${realName}"   class="input-text lh25" size="10"/>
                  </td>
                   <td>
                       <input type="submit" name="button" class="btn btn82 btn_search" value="查询"/>
                       <input type="reset" name="button" class="btn btn82 btn_recycle" value="清空"/>
                   </td>
                </tr>

              </table>
            </div>

             <div  class="box_bottom pb5 pt5 pr10" style="border-top:1px solid #dadada;">
              <div class="search_bar_btn" style="text-align:center;" >

                 <a href="/resource/system/user/addftl" class="ext_btn"><span class="add"></span>添加用户</a>
              </div>
            </div>
			</div>  </div>
			</form>
        <div id="table" class="mt10">
        <div class="box span10 oh">
              <table width="100%" border="0" cellpadding="0" cellspacing="0" class="list_table">
                <tr>
				   <th> <input id="buttonAll" type="checkbox"/></th>
                   <th >用户名</th>
                   <th >真实姓名</th>
                   <th >角色</th>
                   <th>机构/部门</th>
				   <th>状态</th>
				   <th>操作</th>
                </tr>
                  <form action="/resource/system/user/delAllAndExcle" method="post">
                      <input type="hidden" name="loginUserId" value="${loginUser.roleId}"/>
                      <input type="hidden" name="method" id="myMethod"/>

                      <#list pageInfo.list as user >
                          <tr  class="tr" align="center">
                              <td class="td_center">

                                   <#-- <#if (loginUser.userId!=user.userId)>
                                        &lt;#&ndash;2、不能删与自己同级权限的人&ndash;&gt;
                                        <#if (loginUser.roleId<user.roleId)>-->
                                  <input type="hidden" name="roleId" value="${user.roleId}"/>
                                  <input type="checkbox" name="userId"  value="${user.userId}" />

                                      <#--  </#if>
                                    </#if>-->

                              </td>

                              <td><a href="/resource/system/user/look?userId=${user.userId}">${user.username}</a></td>


                              <td>${user.realName}</td>
                              <td>${user.roles.roleName}</td>
                              <td>${user.dept.deptName}</td>
                              <td>
                                  <#if (user.status==0) >
                                      可用
                                  </#if>
                                  <#if (user.status==1) >
                                      冻结
                                  </#if>
                              </td>

                              <td>

                                <#--  <#if (loginUser.roleId<user.roleId)>-->

                                  <#--1、不能禁用自己-->
                                    <#if (loginUser.userId!=user.userId)>
                                        <#--2、不能禁用与自己同级权限的人-->
                                        <#if (loginUser.roleId<user.roleId)>

                                         <#if (user.status==0)>
                                          <a href="/resource/system/user/status?userId=${user.userId}&page=${pageInfo.pageNum}&username=${username}&realName=${realName}">禁用</a> &nbsp;
                                         </#if>

                                          <#if (user.status==1)>
                                              <a href="/resource/system/user/active?userId=${user.userId}&page=${pageInfo.pageNum}&username=${username}&realName=${realName}">启用</a> &nbsp;
                                          </#if>
                                        </#if>

                                      </#if>

                                 <#-- </#if>-->

                                  <a href="/resource/system/user/preEdit?userId=${user.userId}">&nbsp;&nbsp;编辑&nbsp;&nbsp;</a>

                                  <#if (loginUser.userId!=user.userId)>

                                      <#--2、不能删与自己同级权限的人-->
                                        <#if (loginUser.roleId<user.roleId)>

                                        <a href="/resource/system/user/deletOne?userId=${user.userId}&page=${pageInfo.pageNum}&username=${username}&realName=${realName}" >删除</a>
                                        </#if>
                                  </#if>
                              </td>
                          </tr>
                      </#list>
                  </form>


               <tr>
			   <td colspan="2"><input type="button" name="#buttonAll" class="btn btn82 btn_del" value="删除" onclick="deleteAll()" />
			    <input type="button" name="button"  class="btn btn82 btn_export" value="导出" onclick="excel()" />
				</td>
				<td colspan="5" align="right">
				     <div class="page mt10">
						<div class="pagination">
						  <ul >
							  <li class="first-child"><a href="/resource/system/user/list?page=1&username=${username}&realName=${realName}">首页</a></li>
							  <li >
                                 <#-- ${ (type == 'SPOT') ?string('热点词','热点搜索')}-->
                                  <a href="/resource/system/user/list?page=${(pageInfo.prePage<1)?string('1','${pageInfo.prePage}')}&username=${username}&realName=${realName}" >上一页</a>
                              </li>

							  <li><a href="/resource/system/user/list?page=${(pageInfo.nextPage<1)?string('${pageInfo.pages}','${pageInfo.nextPage}')}&username=${username}&realName=${realName}">下一页</a></li>
							  <li ><a href="/resource/system/user/list?page=${pageInfo.pages}&username=${username}&realName=${realName}">末页</a></li>
                              <li ><span>第${pageInfo.pageNum}页</span></li>
                              <li ><span>共${pageInfo.total}条数据</span></li>
                              <li ><span>共${pageInfo.pages}页</span></li>
						  </ul>
						</div>
                     </div>
				</td>
			   </tr>
              </table>			  
		
             
        </div>
     </div>

</body>
</html>
